function _$(id) {
	return document.getElementById(id);
}
function $V(id) {
	return _$(id).val();
}

function getKeyCode(ev) {
	if (window.event)
		return window.event.keyCode;
	return ev.keyCode;
}

var Transport = {
	init : function(cfg) {
		var onMsgFun = this._onmessage;
		var host = window.location.host;
		var location = "ws://" + host + cfg.path;

		if (cfg['onmessage'])
			onMsgFun = cfg['onmessage'];
		if (cfg['host'] && cfg['port'])
			location = "ws://" + cfg['host'] + ":" + cfg['port'] + cfg.path;

		this._ws = new WebSocket(location);
		this._ws.status_div = cfg['status'];
		this._ws.binaryType = "arraybuffer";
		this._ws.onmessage = onMsgFun;
		this._ws.onopen = this._onopen;
		this._ws.onclose = this._onclose;
	},
	send : function(msg) {
		if (!msg)
			return;
		if (typeof (msg) == "string" && msg.length == 0)
			return;
		try {
			this._ws.send(msg);
		} catch (e) {
			alert(e);
		}
	},
	// ------private method------------
	_onopen : function() {
		try {
			_$(this.status_div).innerHTML='Conn server success';
		} catch (e) {
			alert(e);
		}
	},
	_onmessage : function(m) {
		s
		console.log(m.data);
	},
	_onclose : function(m) {
		this._ws = null;
	}
};